import java.util.Stack;

public class MyQueueDiffer {
    class MyQueue {
        Stack<Integer> stackX;
        Stack<Integer> stackY;

        public MyQueue() {
            stackX = new Stack<>();
            stackY = new Stack<>();
        }

        public void push(int x) {
            stackX.push(x);

        }

        public int pop() {
            if(stackY.isEmpty()){
                while(!stackX.isEmpty()){
                    stackY.push(stackX.pop());
                }
            }
            return stackY.pop();
        }

        public int peek() {
            if(stackY.isEmpty()){
                while(!stackX.isEmpty()){
                    stackY.push(stackX.pop());
                }
            }

            return stackY.peek();

        }

        public boolean empty() {
            return stackX.isEmpty()&&stackY.isEmpty();
        }
    }

}
